package net.exoweb.animate.objects
{
    import flash.display.GradientType;
    import flash.geom.Matrix;

    import net.exoweb.animate.objects.DisplayShape;

    public class Radial extends DisplayShape
    {
        private var _radius:Number;
        private var _centerColor:uint;

        public function Radial(radius:Number=1, centerColor:uint=0xFFFFFF, color:uint=0xFFFFFF, bm:String="normal")
        {
            super(color, bm);
            _radius = radius;
            _centerColor = centerColor;
            display();
        }

        public function set radius(v:Number):void
        {
            _radius = v;
            display();
        }

        public function get radius():Number
        {
            return _radius;
        }

        public function set centerColor(v:uint):void
        {
            _centerColor = v;
            display();
        }

        public function get centerColor():uint
        {
            return _centerColor;
        }

        override public function display():void
        {
            graphics.clear();
            var matrix:Matrix = new Matrix();
            matrix.createGradientBox(_radius * 2, _radius * 2, 0, -_radius, -_radius);
            graphics.beginGradientFill(GradientType.RADIAL, [_centerColor, _color], [1, 0], [63, 255], matrix);
            graphics.drawCircle(0, 0, _radius);
            graphics.endFill();
        }
    }
}
